<?php
require_once 'includes/haut.php';
require_once 'includes/donneesFormulaires.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Nos cr&eacute;ations</title>
		<?php include('includes/headLinks.php');?>
	<script src="plugin/jquery.bxSlider/jquery.bxSlider.min.js" type="text/javascript"></script>
	<script src="js/vitrine.js" type="text/javascript"></script>
	</head>
	<body>
		<div id="entete">
		</div>
	
		<div id="navigation">
			<?php include('includes/navigation.php'); ?>
		</div>

		<div id="principal">
			<?php 		
			if (!isset ($_GET['cat1'])||!isset ($_GET['cat2'])){
				header("Location:index.php");
				exit();
			}
			else {
				$cat2 = $_GET['cat2'];
				$cat1 = $_GET['cat1'];
			}?>
			<h2> Nos <?php echo titreVitrine($cat1,$cat2,$tabCat1Cat2);?> </h2>

<!-- 			<form action="rechercheMat.php" method="post" id="formRecherche"> -->
<!-- 				<div class="recherche"> -->
<!-- 					<input type="search" name= "recherche" id="recherche"/> -->
<!-- 					<input type="submit" name="rechercher" value="Rechercher" /> -->
<!-- 					<input type="hidden" name="action" value="rechercher" /> -->
<!-- 					<div class="suggestionsBox" id="suggestions"> -->
<!-- 			 			<img src="images/icones/upArrow.png"  alt="upArrow" />    -->
<!-- 						<div class="suggestionList" id="autoSuggestionsList"> -->
<!-- 						</div> -->
<!-- 					</div> -->
<!-- 				</div> -->
<!-- 			</form> -->


			<?php 
			$req = creation::getCreationByCat($cat1,$cat2);
			$i=1;
			while ($res = $req->fetch()){
				$reqPhotos = photo::getPhotoByCreation($res['id']);
				if ($reqPhotos->rowCount()>0) {
				?>	
				<div id="<?php echo $res['id'];?>" class="prefix_1 listeCreations suffix_1"
					style="margin-bottom: 30px; margin-top: 20px">
					<div class="slider">
						<ul id="slider<?php echo $i;?>">
							<li>							
								<?php
								$j = -1;
								while ($resPhotos = $reqPhotos->fetch()){
// 									premiere page avec infos
									if ($j < 0) { ?>
										<div class="left">
											<img class="photo" src="images/creations/<?php echo($res['id'].'/'.$resPhotos['nom']);?>" />
										</div>
										<div class="right">
											<div class="album">
												<?php echo $res['modele']; ?></br>
												<?php  if ($res['description']!="") echo $res['description']."</br>"; ?>
												<?php if ($res['taille']!="")  echo "Taille : ".$res['taille']."</br>"; ?>
												<?php echo $res['prix']; ?>&euro;</br>
												<?php echo $res['dispo']; ?> mod&egrave;les disponibles</br>
											</div>
											<div class="band">
											<?php if ($niveau==1) {?>
												<a class="edit" href="ajoutCreation.php?action=modifier&idCreation=<?php echo $res['id'];?>">Modifier</a><br /> 
												<span class="delete" data-id="<?php echo $res['id'];?>">Supprimer</span>
											<?php } else if ($niveau==0){?>
												<span class="addFavori" data-idCreation="<?php echo $res['id'];?>" data-idClient="<?php echo $client->getId();?>">Ajouter aux favoris</span>
											<?php } ?>
											</div>
										</div>
										
										</li><li>
												
									<?php } else{
	// 									pages suivantes avec 3 photos
										if ($j % 3 == 0 && $j > 0) {?>
											</li><li>
										<?php } ?>
										<div class="elementSlider">
											<img class="photo" src="images/creations/<?php echo($res['id'].'/'.$resPhotos['nom']);?>" />
										</div> 
									<?php }
						 			$j++;
					 			} 
					 			$reqPhotos->closeCursor();?>
							</li>
						</ul>
					</div>
				</div>
				<?php 
				}
				$i++;
			} $req->closeCursor();?>

		</div>

		<div id="form_connexion">
			<?php include('includes/formConnexion.php'); ?>
		</div>
	</body>
</html>
